package com.sdx.console.utils;

import java.util.Random;

/**
 * @ClassName CodeUtils
 * @Description
 * @Author kangbin
 * @Date 2019/11/5 14:23
 */
public class CodeUtils {

    /**
     * 生产随机函数
     * @param length
     * @return
     */
    public static String getCode( int length ){
        String base = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for ( int i = 0; i < length; i++ )
        {
            int number = random.nextInt( base.length() );
            sb.append( base.charAt( number ) );
        }
        return sb.toString();
    }
}
